<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2930：[Poi1999]梦游者</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Poi1999]梦游者</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Poi1999]梦游者</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [Poi1999]梦游者                </h1>
                <p>时间限制：1s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div style="text-indent: 24pt"><span style="font-size: 12pt">在一幢豪华的公寓中，有一块面积巨大的正方形大厅。这个大厅的地板被分成了</span><span style="font-size: 12pt">3<sup>k</sup></span><span style="font-size: 12pt">&times;</span><span style="font-size: 12pt">3<sup>k</sup></span><span style="font-size: 12pt">个格子，每个格子上都被铺了一块与格子面积大小一致的瓷砖，如此的布置使得整个大厅显得更加的气派。遗憾的是，地板上有一块瓷砖因为损坏而被移走了，这就留下了一个洞。</span></div>
<div style="text-indent: 24pt"><span style="font-size: 12pt">为了方便的表示这个洞的位置，我们将大厅的地板置于一个平面直角坐标系中，最西南方的格子的坐标为</span><span style="font-size: 12pt">(1,1)</span><span style="font-size: 12pt">，往东是</span><span style="font-size: 12pt">X</span><span style="font-size: 12pt">轴的正方向，往北是</span><span style="font-size: 12pt">Y</span><span style="font-size: 12pt">轴的正方向。</span></div>
<div style="text-indent: 24pt"><span style="font-size: 12pt">一个梦游者正在这个大厅里游荡。梦游者从西南方</span><span style="font-size: 12pt">(1,1)</span><span style="font-size: 12pt">出发，每次可以往四周的方向（东</span><span style="font-size: 12pt">E</span><span style="font-size: 12pt">、南</span><span style="font-size: 12pt">S</span><span style="font-size: 12pt">、西</span><span style="font-size: 12pt">W</span><span style="font-size: 12pt">、北</span><span style="font-size: 12pt">N</span><span style="font-size: 12pt">）移动，要走便所有的格子而不重复。他的行动路线十分怪异，例如</span><span style="font-size: 12pt">k=1</span><span style="font-size: 12pt">，即地板是</span><span style="font-size: 12pt">3</span><span style="font-size: 12pt">&times;</span><span style="font-size: 12pt">3</span><span style="font-size: 12pt">规模时，他的行走路线为：</span><span style="font-size: 12pt">D<sub>1</sub>=EENNWSWN</span><span style="font-size: 12pt">；当</span><span style="font-size: 12pt">k=2</span><span style="font-size: 12pt">时，地板是</span><span style="font-size: 12pt">9</span><span style="font-size: 12pt">&times;</span><span style="font-size: 12pt">9</span><span style="font-size: 12pt">规模，他的行走路线</span><span style="font-size: 12pt">D<sub>2</sub>=NNEESWSEENNEESWSEEEENNWSWNNEENNWSWNNEENNWSWNWWWSSENESSSSWWNENWWSSWWNENWNEENNWSWN</span><span style="font-size: 12pt">。</span></div>
<div style="text-indent: 24pt"><span style="font-size: 12pt">直观的将路线画在图上如下图：</span></div>
<div style="text-indent: 24pt"></div>
<div style="text-indent: 24pt"><span style="font-size: 12pt"><img height="234" width="354" alt="" src="../file/2930_0.jpg" /></span></div>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">总的来说，当地板规模是</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">3<sup>k+1</sup></font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">&times;</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">3<sup>k+1</sup></font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">时，梦游者的路径为</span><span lang="EN-US" style="font-size: 12pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">D<sub>k+1 </sub>= a(D<sub>k</sub>) E a(D<sub>k</sub>) E D<sub>k</sub> N D<sub>k</sub> N D<sub>k</sub> W c(D<sub>k</sub>) S b(D<sub>k</sub>) W b(D<sub>k</sub>) N D<sub>k</sub><o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其中，</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">a()</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">b()</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">c()</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">均表示一种字母置换，具体如下：</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><img height="110" width="220" alt="" src="../file/2930_1.jpg" /></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"></p>
<p>
<p></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"></p>
</p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">例如，</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">a(SEN)=WNE, b(SEN)=ESW, c(SEN)=NWS<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">现在，梦游者正站在坐标为</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">(x1,y1)</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的地板上，而没有因为瓷砖损坏造成了一个洞的地板坐标为</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">(x2,y2)</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。你能求出可怜的梦游者将在第几步后跌入洞中么？</span><span lang="EN-US" style="font-size: 12pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"></p></p><hr/><h3>输入格式</h3><p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第一行有一个数字</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">k</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">1&lt;=k&lt;=60</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">），表示大厅地板的规模是</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">3<sup>k</sup></font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">&times;</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">3<sup>k</sup></font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span><span lang="EN-US" style="font-size: 12pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第二行有两个数字，</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">x1</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">y1</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">表示梦游者</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">L</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">先生开始所站的坐标位置。</span><span lang="EN-US" style="font-size: 12pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第三行有两个数字，</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">x2</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman">y2</font></span><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">表示洞的坐标位置。</span><span lang="EN-US" style="font-size: 12pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以保证的是梦游者在若干步之后一定会跌入洞中。</span><span lang="EN-US" style="font-size: 12pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span lang="EN-US" style="font-size: 12pt"><o:p><font face="Times New Roman">&nbsp;</font></o:p></span></p>
<p></p></p><hr/><h3>输出格式</h3><p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">输出文件只有一行，一个数字，表示多少步后，梦游者会跌如洞中。</span><span lang="EN-US" style="font-size: 12pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp;</span><o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 24pt; mso-char-indent-count: 2.0"><span lang="EN-US" style="font-size: 12pt"><font face="Times New Roman"><o:p></o:p></font></span></p></p><hr/><h3>样例输入</h3><pre>2
3 2
7 2

 

</pre><hr/><h3>样例输出</h3><pre>20
</pre><hr/><h3>提示</h3><p>没有写明提示</p><hr/><h3>题目来源</h3><p>没有写明来源</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2930" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2930" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>